<?php

class categoria{
	#NOME DA TABELA -> admin_projetos

	function pega($id){
	$sql = mysql_query("select * from noticias_categoria WHERE id = '$id'");
	
	
	$row = mysql_fetch_array($sql);
	$lista = array(
	id=>$row['id'],
	titulo=>$row['titulo'],
	obs=>$row['obs'],
	ativo=>$row['ativo']
	);
	
	
	return $lista;
	
	}




	function lista($where,$order,$limit){
	$sql = mysql_query("select * from noticias_categoria $where $order $limit");
	
	$x=0;
	while($row = mysql_fetch_array($sql)){
	$x++;
	
	$lista[$x] = array(
	id=>$row['id'],
	titulo=>$row['titulo'],
	obs=>$row['obs'],
	ativo=>$row['ativo']
	);
	
	}	
	
	return $lista;
	
	}
	
	
	function cadastra($titulo,$obs,$ativo){
	$sql= mysql_query("insert into noticias_categoria values(
	'0',
	'$titulo',
	'$obs',
	'$ativo'
	)");	
	
	if($sql == true){
	return true;
	}else{
	return false;
	}
	}
	
	
	
	function edita($id,$titulo,$obs,$ativo){
	$sql= mysql_query("UPDATE noticias_categoria SET 
	titulo 		= '$titulo',
	obs 		= '$obs',
	ativo 		= $ativo
	WHERE id = '$id'
	");	
	
	if($sql == true){
	return true;
	}else{
	return false;
	}
	}
	
	
	
	function deleta($id){
	$sql= mysql_query("DELETE FROM noticias_categoria WHERE id = '$id'
	");	
	
	if($sql == true){
	return true;
	}else{
	return false;
	}
	}
	
	
	function status($id,$status){
	$dados = $this->pega($id);
	$sql = mysql_query("UPDATE noticias_categoria SET ativo = '$status' WHERE id = '$id'");
	$status == 1 ? $ativo = "ativo.gif" : $ativo = "inativo.gif";  
	
	if($sql){
	return $ativo;
	}else{
	return false;
		}
		
	
	}
	
	
	
	
	
	
	
	####SUBCATEGORIAS NIVEL 1 - SUBCATEGORIA
	function pegan1($id){
	$sql = mysql_query("select * from categoria_n1 WHERE id = '$id'");
	
	
	$row = mysql_fetch_array($sql);
	$lista = array(
	id=>$row['id'],
	n1=>$row['n1'],
	titulo=>$row['titulo'],
	cat=>$row['cat']
	);
	
	
	return $lista;
	
	}


	function listan1($where,$order,$limit){
	$sql = mysql_query("select * from categoria_n1 $where $order $limit");
	
	$x=0;
	while($row = mysql_fetch_array($sql)){
	$x++;
	
	$lista[$x] = array(
	id=>$row['id'],
	titulo=>$row['titulo'],
	cat=>$row['cat']
	);
	
	}	
	
	return $lista;
	
	}
	function cadastran1($titulo,$idcat){
	$sql= mysql_query("insert into categoria_n1 values(
	'0',
	'$idcat',
	'$titulo'
	)");	
	
	if($sql == true){
	return true;
	}else{
	return false;
	}
	}
	
	function deletan1($id){
	$sql= mysql_query("DELETE FROM categoria_n1 WHERE id = '$id'");	
	
	if($sql == true){
	return true;
	}else{
	return false;
	}
	}
	
	####  FIM SUBCATEGORIAS NIVEL 1 - SUBCATEGORIA######################
	
	
	
	
	
	
	
	
	####SUBCATEGORIAS NIVEL 2 - SUBCATEGORIA
	function pegan2($id){
	$sql = mysql_query("select * from categoria_n2 WHERE id = '$id'");
	
	
	$row = mysql_fetch_array($sql);
	$lista = array(
	id=>$row['id'],
	n1=>$row['n1'],
	titulo=>$row['titulo'],
	cat=>$row['cat']
	);
	
	
	return $lista;
	
	}
	
	
	function listan2($where,$order,$limit){
	$sql = mysql_query("select * from categoria_n2 $where $order $limit");
	
	$x=0;
	while($row = mysql_fetch_array($sql)){
	$x++;
	
	$lista[$x] = array(
	id=>$row['id'],
	n1=>$row['n1'],
	titulo=>$row['titulo'],
	cat=>$row['cat']
	);
	
	}	
	
	return $lista;
	
	}
	function cadastran2($titulo,$idcat,$n1){
	$sql= mysql_query("insert into categoria_n2 values(
	'0',
	'$idcat',
	'$n1',
	'$titulo'
	)");	
	
	if($sql == true){
	return true;
	}else{
	return false;
	}
	}
	
	function deletan2($id){
	$sql= mysql_query("DELETE FROM categoria_n2 WHERE id = '$id'");	
	
	if($sql == true){
	return true;
	}else{
	return false;
	}
	}
	
	####  FIM SUBCATEGORIAS NIVEL 1 - SUBCATEGORIA######################
	
	



	
	
	####SUBCATEGORIAS NIVEL 3 - SUBCATEGORIA
	function pegan3($id){
	$sql = mysql_query("select * from categoria_n3 WHERE id = '$id'");
	
	
	$row = mysql_fetch_array($sql);
	$lista = array(
	id=>$row['id'],
	n1=>$row['n1'],
	n2=>$row['n2'],
	titulo=>$row['titulo'],
	cat=>$row['cat']
	);
	
	
	return $lista;
	
	}
	
	
	function listan3($where,$order,$limit){
	$sql = mysql_query("select * from categoria_n3 $where $order $limit");
	
	$x=0;
	while($row = mysql_fetch_array($sql)){
	$x++;
	
	$lista[$x] = array(
	id=>$row['id'],
	n1=>$row['n1'],
	n2=>$row['n2'],
	titulo=>$row['titulo'],
	cat=>$row['cat']
	);
	
	}	
	
	return $lista;
	
	}
	function cadastran3($titulo,$idcat,$n1,$n2){
	$sql= mysql_query("insert into categoria_n3 values(
	'0',
	'$idcat',
	'$n1',
	'$n2',
	'$titulo'
	)");	
	
	if($sql == true){
	return true;
	}else{
	return false;
	}
	}
	
	function deletan3($id){
	$sql= mysql_query("DELETE FROM categoria_n3 WHERE id = '$id'");	
	
	if($sql == true){
	return true;
	}else{
	return false;
	}
	}
	
	####  FIM SUBCATEGORIAS NIVEL 3 - SUBCATEGORIA######################
	
	
	
	
	####SUBCATEGORIAS NIVEL 4 - SUBCATEGORIA
	function pegan4($id){
	$sql = mysql_query("select * from categoria_n4 WHERE id = '$id'");
	
	
	$row = mysql_fetch_array($sql);
	$lista = array(
	id=>$row['id'],
	n1=>$row['n1'],
	n2=>$row['n2'],
	n3=>$row['n3'],
	titulo=>$row['titulo'],
	cat=>$row['cat']
	);
	
	
	return $lista;
	
	}
	
	
	function listan4($where,$order,$limit){
	$sql = mysql_query("select * from categoria_n4 $where $order $limit");
	
	$x=0;
	while($row = mysql_fetch_array($sql)){
	$x++;
	
	$lista[$x] = array(
	id=>$row['id'],
	n1=>$row['n1'],
	n2=>$row['n2'],
	n3=>$row['n3'],
	titulo=>$row['titulo'],
	cat=>$row['cat']
	);
	
	}	
	
	return $lista;
	
	}
	function cadastran4($titulo,$idcat,$n1,$n2,$n3){
	$sql= mysql_query("insert into categoria_n4 values(
	'0',
	'$idcat',
	'$n1',
	'$n2',
	'$n3',
	'$titulo'
	)");	
	
	if($sql == true){
	return true;
	}else{
	return false;
	}
	}
	
	function deletan4($id){
	$sql= mysql_query("DELETE FROM categoria_n4 WHERE id = '$id'");	
	
	if($sql == true){
	return true;
	}else{
	return false;
	}
	}
	
	####  FIM SUBCATEGORIAS NIVEL 4 - SUBCATEGORIA######################
	
	
	
	
	
	
	
	
	
	
	
	####SUBCATEGORIAS NIVEL 5 - SUBCATEGORIA
	function pegan5($id){
	$sql = mysql_query("select * from categoria_n5 WHERE id = '$id'");
	
	
	$row = mysql_fetch_array($sql);
	$lista = array(
	id=>$row['id'],
	n1=>$row['n1'],
	n2=>$row['n2'],
	n3=>$row['n3'],
	n4=>$row['n4'],
	titulo=>$row['titulo'],
	cat=>$row['cat']
	);
	
	
	return $lista;
	
	}
	
	
	function listan5($where,$order,$limit){
	$sql = mysql_query("select * from categoria_n5 $where $order $limit");
	
	$x=0;
	while($row = mysql_fetch_array($sql)){
	$x++;
	
	$lista[$x] = array(
	id=>$row['id'],
	n1=>$row['n1'],
	n2=>$row['n2'],
	n3=>$row['n3'],
	n4=>$row['n4'],
	titulo=>$row['titulo'],
	cat=>$row['cat']
	);
	
	}	
	
	return $lista;
	
	}
	function cadastran5($titulo,$idcat,$n1,$n2,$n3,$n4){
	$sql= mysql_query("insert into categoria_n5 values(
	'0',
	'$idcat',
	'$n1',
	'$n2',
	'$n3',
	'$n4',
	'$titulo'
	)");	
	
	if($sql == true){
	return true;
	}else{
	return false;
	}
	}
	
	function deletan5($id){
	$sql= mysql_query("DELETE FROM categoria_n5 WHERE id = '$id'");	
	
	if($sql == true){
	return true;
	}else{
	return false;
	}
	}
	
	####  FIM SUBCATEGORIAS NIVEL 5 - SUBCATEGORIA######################

	
	
	
	
	####SUBCATEGORIAS NIVEL 6 - SUBCATEGORIA
	function pegan6($id){
	$sql = mysql_query("select * from categoria_n6 WHERE id = '$id'");
	
	
	$row = mysql_fetch_array($sql);
	$lista = array(
	id=>$row['id'],
	n1=>$row['n1'],
	n2=>$row['n2'],
	n3=>$row['n3'],
	n4=>$row['n4'],
	n5=>$row['n5'],
	titulo=>$row['titulo'],
	cat=>$row['cat']
	);
	
	
	return $lista;
	
	}
	
	
	function listan6($where,$order,$limit){
	$sql = mysql_query("select * from categoria_n6 $where $order $limit");
	
	$x=0;
	while($row = mysql_fetch_array($sql)){
	$x++;
	
	$lista[$x] = array(
	id=>$row['id'],
	n1=>$row['n1'],
	n2=>$row['n2'],
	n3=>$row['n3'],
	n4=>$row['n4'],
	n5=>$row['n5'],
	titulo=>$row['titulo'],
	cat=>$row['cat']
	);
	
	}	
	
	return $lista;
	
	}
	function cadastran6($titulo,$idcat,$n1,$n2,$n3,$n4,$n5){
	$sql= mysql_query("insert into categoria_n6 values(
	'0',
	'$idcat',
	'$n1',
	'$n2',
	'$n3',
	'$n4',
	'$n5',
	'$titulo'
	)");	
	
	if($sql == true){
	return true;
	}else{
	return false;
	}
	}
	
	function deletan6($id){
	$sql= mysql_query("DELETE FROM categoria_n6 WHERE id = '$id'");	
	
	if($sql == true){
	return true;
	}else{
	return false;
	}
	}
	
	####  FIM SUBCATEGORIAS NIVEL 6 - SUBCATEGORIA######################
	
	
	
	
	####SUBCATEGORIAS NIVEL 7 - SUBCATEGORIA
	function pegan7($id){
	$sql = mysql_query("select * from categoria_n7 WHERE id = '$id'");
	
	
	$row = mysql_fetch_array($sql);
	$lista = array(
	id=>$row['id'],
	n1=>$row['n1'],
	n2=>$row['n2'],
	n3=>$row['n3'],
	n4=>$row['n4'],
	n5=>$row['n5'],
	n6=>$row['n6'],
	titulo=>$row['titulo'],
	cat=>$row['cat']
	);
	
	
	return $lista;
	
	}
	
	
	function listan7($where,$order,$limit){
	$sql = mysql_query("select * from categoria_n7 $where $order $limit");
	
	$x=0;
	while($row = mysql_fetch_array($sql)){
	$x++;
	
	$lista[$x] = array(
	id=>$row['id'],
	n1=>$row['n1'],
	n2=>$row['n2'],
	n3=>$row['n3'],
	n4=>$row['n4'],
	n5=>$row['n5'],
	n6=>$row['n6'],
	titulo=>$row['titulo'],
	cat=>$row['cat']
	);
	
	}	
	
	return $lista;
	
	}
	function cadastran7($titulo,$idcat,$n1,$n2,$n3,$n4,$n5,$n6){
	$sql= mysql_query("insert into categoria_n7 values(
	'0',
	'$idcat',
	'$n1',
	'$n2',
	'$n3',
	'$n4',
	'$n5',
	'$n6',
	'$titulo'
	)");	
	
	if($sql == true){
	return true;
	}else{
	return false;
	}
	}
	
	function deletan7($id){
	$sql= mysql_query("DELETE FROM categoria_n7 WHERE id = '$id'");	
	
	if($sql == true){
	return true;
	}else{
	return false;
	}
	}
	
	####  FIM SUBCATEGORIAS NIVEL 7 - SUBCATEGORIA######################
	
	
	
	
	
	
	
	
	
	####SUBCATEGORIAS NIVEL 8 - SUBCATEGORIA
	function pegan8($id){
	$sql = mysql_query("select * from categoria_n8 WHERE id = '$id'");
	
	
	$row = mysql_fetch_array($sql);
	$lista = array(
	id=>$row['id'],
	n1=>$row['n1'],
	n2=>$row['n2'],
	n3=>$row['n3'],
	n4=>$row['n4'],
	n5=>$row['n5'],
	n6=>$row['n6'],
	n7=>$row['n7'],
	titulo=>$row['titulo'],
	cat=>$row['cat']
	);
	
	
	return $lista;
	
	}
	
	
	function listan8($where,$order,$limit){
	$sql = mysql_query("select * from categoria_n8 $where $order $limit");
	
	$x=0;
	while($row = mysql_fetch_array($sql)){
	$x++;
	
	$lista[$x] = array(
	id=>$row['id'],
	n1=>$row['n1'],
	n2=>$row['n2'],
	n3=>$row['n3'],
	n4=>$row['n4'],
	n5=>$row['n5'],
	n6=>$row['n6'],
	n7=>$row['n7'],
	titulo=>$row['titulo'],
	cat=>$row['cat']
	);
	
	}	
	
	return $lista;
	
	}
	function cadastran8($titulo,$idcat,$n1,$n2,$n3,$n4,$n5,$n6,$n7){
	$sql= mysql_query("insert into categoria_n8 values(
	'0',
	'$idcat',
	'$n1',
	'$n2',
	'$n3',
	'$n4',
	'$n5',
	'$n6',
	'$n7',
	'$titulo'
	)");	
	
	if($sql == true){
	return true;
	}else{
	return false;
	}
	}
	
	function deletan8($id){
	$sql= mysql_query("DELETE FROM categoria_n8 WHERE id = '$id'");	
	
	if($sql == true){
	return true;
	}else{
	return false;
	}
	}
	
	####  FIM SUBCATEGORIAS NIVEL 7 - SUBCATEGORIA######################
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	### LISTA DE CATEGORIAS
	
	function cadastraLista($cat,$n1,$n2,$n3,$n4,$n5,$n6,$n7,$n8){
		$sql	= mysql_query("insert into categoria_lista values('','$cat','$n1','$n2','$n3','$n4','$n5','$n6','$n7','$n8')");	
	
		if($sql == true){
		return true;
		}else{
		return false;
		}
	
	
		}
		
		
	function deletaLista($id){
	$sql= mysql_query("DELETE FROM categoria_lista WHERE id = '$id'");	
	
	if($sql == true){
	return true;
	}else{
	return false;
	}
	}
	
	
	
	
	
	}


?>